package com.buu.manager.controller;

import com.buu.common.annotation.Log;
import com.buu.common.utils.PageUtils;
import com.buu.common.utils.Query;
import com.buu.education.domain.EducationEvaluateDO;
import com.buu.education.service.EvaluateService;
import com.buu.evaluate.domain.EvaluateInfoDO;
import com.buu.manager.domain.EduDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 信息统计
 */
@RequestMapping("/statistics")
@Controller
public class StatisticsController {

    @Autowired
    private EvaluateService evaluateService;

    @GetMapping("/view")
    String view(Model model) {
        return "manager/statistics/statistics";
    }

    @GetMapping("/list")
    @ResponseBody
    PageUtils list(@RequestParam Map<String, Object> params) {
        // 查询列表数据
        Query query = new Query(params);
        List<EducationEvaluateDO> eduList = evaluateService.statisticslist(query);
        int total = evaluateService.statisticslistcount(query);
        PageUtils pageUtil = new PageUtils(eduList, total);
        return pageUtil;
    }

    @Log("编辑评价单信息")
    @GetMapping("/evadetail/{userId}")
    String evadetail(Model model, @PathVariable("userId") Long userId) {
        model.addAttribute("userId", userId);
        return "manager/statistics/evadetail";
    }

    @GetMapping("/evaDetailList")
    @ResponseBody
    PageUtils evaDetailList(@RequestParam Map<String, Object> params) {
        // 查询列表数据
        List<EducationEvaluateDO> eduList = evaluateService.evaDetailList(params);
        int total = eduList.size();
        PageUtils pageUtil = new PageUtils(eduList, total);
        return pageUtil;
    }
}
